#ifndef SYSYF_DEADCODEELI_H
#define SYSYF_DEADCODEELI_H

#include "Pass.h"
#include "Module.h"

class DeadCodeEli : public Pass
{
public:
    DeadCodeEli(Module *module) : Pass(module) {}
    void execute() final;
    void mark(Function *func);
    void sweep(Function *func);
    bool is_critical(Instruction *inst); //判断一个语句是否为关键语句
    BasicBlock *nearest_marked_postdominator(Instruction *inst);//获得最近的有效后支配节点
    const std::string get_name() const override { return name; }

private:
    Function *func_;
    std::map<Instruction *, bool> inst_mark;
    const std::string name = "DeadCodeElimination";
};

#endif // SYSYF_DEADCODEELI_H
